package p2000;

import java.util.HashMap;
import java.util.Map;

/**
 * @author pengjz <br>
 * @version 1.0 <br>
 * @date 2022/2/9 14:22 <br>
 */
public class Leetcode_2006 {

    public int countKDifference(int[] nums, int k) {
        Map<Integer, Integer> result = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            for (int j = i; j < nums.length; j++) {
                int abs = Math.abs(nums[i] - nums[j]);
                int temp = result.getOrDefault(abs, 0);
                result.put(abs, temp + 1);
            }
        }
        return result.getOrDefault(k, 0);
    }
}
